<template>
  <div>
    <el-breadcrumb>
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item><a href="javascript:;">权限管理</a></el-breadcrumb-item>
      <el-breadcrumb-item>权限列表</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card class='box-card'>
      <el-table
        :data="rightsList"
        border
        stripe
        style="width: 100%"
      >
        <el-table-column
          type="index"
          label="#"
        >
        </el-table-column>

        <el-table-column
          prop="authName"
          label="用户名"
        >
        </el-table-column>
        <el-table-column
          prop="path"
          label="路径"
        >
        </el-table-column>
        <el-table-column
          prop="level"
          label="权限级别"
        >
          <template v-slot='{row}'>
            <el-tag
              v-if='row.level=== "0"'
              effect="dark"
            >等级一
            </el-tag>
            <el-tag
              v-else-if='row.level=== "1"'
              type="success"
              effect="dark"
            >等级二
            </el-tag>
            <el-tag
              v-else
              type="warning"
              effect="dark"
            >等级三
            </el-tag>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>
<script>
export default {
  props: [],
  data () {
    return {
 //列表形式的权限
            rightsList:[]
            
    }
  },
  mounted () {

  },
  created(){
      this.getRightsList()
  },
  methods: {
    //   获取权限列表
     async getRightsList(){
            const {data:res} = await this.$http.get('rights/list')
            //如果返回状态为异常状态则报错并返回
            if (res.meta.status !== 200)
                return this.$message.error('获取权限列表失败')
            //如果返回状态正常，将请求的数据保存在data中
            this.rightsList = res.data
        }
  }
}
</script>
<style lang="less" scoped>

</style>